// app.js
const express = require('express');
const app = express();
const port = 3000;
const ConfigHandler = require('./Handler.js')
const myParser = require("body-parser");

app.use(myParser.json({limit: '200mb'}));
app.use(myParser.urlencoded({limit: '200mb', extended: true}));
app.get('/', (req, res) => {
  res.send('Hello, Docker World!');
});

app.post('/', (req, res) => {
  const body = req.body;
  const handle = new ConfigHandler(body.data)
  let k = null;
  try{
     k = handle.handle()
  }catch(e){
     console.log(e.message)
     k = e.message
  }
  res.send(k);
});

app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});
